<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Dijkstra's algorithm</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Dijkstra's_algorithm"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Dijkstra_s_algorithm rootpage-Dijkstra_s_algorithm skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Dijkstra's algorithm</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">Not to be confused with <a href="Dykstra's_projection_algorithm" title="Dykstra's projection algorithm">Dykstra's projection algorithm</a>.</div>
<p class="mw-empty-elt">
</p>
<style data-mw-deduplicate="TemplateStyles:r1295905060">
/* start https://en.wikipedia.org/ */
.mw-parser-output .infobox-subbox{padding:0;border:none;margin:-3px;width:auto;min-width:100%;font-size:100%;clear:none;float:none;background-color:transparent}.mw-parser-output .infobox-3cols-child{margin:auto}.mw-parser-output .infobox .navbar{font-size:100%}@media screen{html.skin-theme-clientpref-night .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media(min-width:640px){body.skin--responsive .mw-parser-output .infobox-table{display:table!important}body.skin--responsive .mw-parser-output .infobox-table>caption{display:table-caption!important}body.skin--responsive .mw-parser-output .infobox-table>tbody{display:table-row-group}body.skin--responsive .mw-parser-output .infobox-table th,body.skin--responsive .mw-parser-output .infobox-table td{padding-left:inherit;padding-right:inherit}}
/* end https://en.wikipedia.org/ */
</style><table class="infobox"><caption class="infobox-title">Dijkstra's algorithm</caption><tbody><tr><td colspan="2" class="infobox-image"><div class="infobox-caption">Dijkstra's algorithm to find the shortest path between <i>a</i> and <i>b</i>. It picks the unvisited vertex with the lowest distance, calculates the distance through it to each unvisited neighbor, and updates the neighbor's distance if smaller. Mark visited (set to red) when done with neighbors.</div></td></tr><tr><th scope="row" class="infobox-label">Class</th><td class="infobox-data"><a href="Search_algorithm" title="Search algorithm">Search algorithm</a><br><a href="Greedy_algorithm" title="Greedy algorithm">Greedy algorithm</a><br><a href="Dynamic_programming" title="Dynamic programming">Dynamic programming</a><sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup></td></tr><tr><th scope="row" class="infobox-label">Data structure</th><td class="infobox-data"><a href="Graph_(data_structure)" class="mw-redirect" title="Graph (data structure)">Graph</a><br>Usually used with <a href="Priority_queue" title="Priority queue">priority queue</a> or <a href="Heap_(data_structure)" title="Heap (data structure)">heap</a> for optimization<sup id="cite_ref-FOOTNOTECormenLeisersonRivestStein2001_2-0" class="reference"><a href="#cite_note-FOOTNOTECormenLeisersonRivestStein2001-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEFredmanTarjan1987_3-0" class="reference"><a href="#cite_note-FOOTNOTEFredmanTarjan1987-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup></td></tr><tr><th scope="row" class="infobox-label"><a href="Best%2C_worst_and_average_case" title="Best, worst and average case">Worst-case</a> <a href="Time_complexity" title="Time complexity">performance</a></th><td class="infobox-data"><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Theta (|E|+|V|\log |V|)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">Θ<!-- Θ --></mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Theta (|E|+|V|\log |V|)}</annotation>
</semantics>
</math></span><img src="./e22162be85d06b346f3b7f7aad9746da0c1019c9.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:19.435ex; height:2.843ex;" alt="{\displaystyle \Theta (|E|+|V|\log |V|)}" loading="lazy"></span><sup id="cite_ref-FOOTNOTEFredmanTarjan1987_3-1" class="reference"><a href="#cite_note-FOOTNOTEFredmanTarjan1987-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup></td></tr></tbody></table>
<p><b>Dijkstra's algorithm</b> (<span class="rt-commentedText nowrap"><span class="IPA nopopups noexcerpt" lang="en-fonipa">/<span style="border-bottom:1px dotted"><span title="/ˈ/: primary stress follows">ˈ</span><span title="'d' in 'dye'">d</span><span title="/aɪ/: 'i' in 'tide'">aɪ</span><span title="'k' in 'kind'">k</span><span title="'s' in 'sigh'">s</span><span title="'t' in 'tie'">t</span><span title="'r' in 'rye'">r</span><span title="/ə/: 'a' in 'about'">ə</span><span title="'z' in 'zoom'">z</span></span>/</span></span> <i title="English pronunciation respelling"><span style="font-size:90%">DYKE</span>-strəz</i>) is an <a href="Algorithm" title="Algorithm">algorithm</a> for finding the <a href="Shortest_path_problem" title="Shortest path problem">shortest paths</a> between <a href="Vertex_(graph_theory)" title="Vertex (graph theory)">nodes</a> in a weighted <a href="Graph_(abstract_data_type)" title="Graph (abstract data type)">graph</a>, which may represent, for example, a <a href="Road_network" class="mw-redirect" title="Road network">road network</a>. It was conceived by computer scientist <a href="Edsger_W._Dijkstra" title="Edsger W. Dijkstra">Edsger W. Dijkstra</a> in 1956 and published three years later.<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Dijkstra_Interview2_5-0" class="reference"><a href="#cite_note-Dijkstra_Interview2-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Dijkstra19592_6-0" class="reference"><a href="#cite_note-Dijkstra19592-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup>
</p><p>Dijkstra's algorithm finds the shortest path from a given source node to every other node.<sup id="cite_ref-mehlhorn_7-0" class="reference"><a href="#cite_note-mehlhorn-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup><sup class="reference nowrap"><span title="Pages: 196–206">: 196–206 </span></sup> It can be used to find the shortest path to a specific destination node, by terminating the algorithm after determining the shortest path to the destination node. For example, if the nodes of the graph represent cities, and the costs of edges represent the distances between pairs of cities connected by a direct road, then Dijkstra's algorithm can be used to find the shortest route between one city and all other cities. A common application of shortest path algorithms is network <a href="Routing_protocol" title="Routing protocol">routing protocols</a>, most notably <a href="IS-IS" title="IS-IS">IS-IS</a> (Intermediate System to Intermediate System) and <a href="Open_Shortest_Path_First" title="Open Shortest Path First">OSPF</a> (Open Shortest Path First). It is also employed as a <a href="Subroutine" class="mw-redirect" title="Subroutine">subroutine</a> in algorithms such as <a href="Johnson's_algorithm" title="Johnson's algorithm">Johnson's algorithm</a>.
</p><p>The algorithm uses a <a href="Priority_queue#Min-priority_queue" title="Priority queue">min-priority queue</a> <a href="Data_structure" title="Data structure">data structure</a> for selecting the shortest paths known so far. Before more advanced priority queue structures were discovered, Dijkstra's original algorithm ran in <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Theta (|V|^{2})}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">Θ<!-- Θ --></mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<msup>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Theta (|V|^{2})}</annotation>
</semantics>
</math></span><img src="./5dbb38dcf2365c1dbf786871f4014dd1a2762df7.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:7.753ex; height:3.343ex;" alt="{\displaystyle \Theta (|V|^{2})}" loading="lazy"></span> <a href="Time_complexity" title="Time complexity">time</a>, where <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle |V|}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle |V|}</annotation>
</semantics>
</math></span><img src="./9ddcffc28643ac01a14dd0fb32c3157859e365a7.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:3.081ex; height:2.843ex;" alt="{\displaystyle |V|}" loading="lazy"></span> is the number of nodes.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTELeyzorekGrayJohnsonLadew1957_9-0" class="reference"><a href="#cite_note-FOOTNOTELeyzorekGrayJohnsonLadew1957-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> <a href="#CITEREFFredmanTarjan1984">Fredman & Tarjan 1984</a> proposed a <a href="Fibonacci_heap" title="Fibonacci heap">Fibonacci heap</a> priority queue to optimize the running time complexity to <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Theta (|E|+|V|\log |V|)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">Θ<!-- Θ --></mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Theta (|E|+|V|\log |V|)}</annotation>
</semantics>
</math></span><img src="./e22162be85d06b346f3b7f7aad9746da0c1019c9.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:19.435ex; height:2.843ex;" alt="{\displaystyle \Theta (|E|+|V|\log |V|)}" loading="lazy"></span>. This is <a href="Asymptotic_computational_complexity" title="Asymptotic computational complexity">asymptotically</a> the fastest known single-source <a href="Shortest_path_problem" title="Shortest path problem">shortest-path algorithm</a> for arbitrary <a href="Directed_graph" title="Directed graph">directed graphs</a> with unbounded non-negative weights. However, specialized cases (such as bounded/integer weights, directed acyclic graphs etc.) can be <a class="mw-selflink-fragment" href="#Specialized_variants">improved further</a>. If preprocessing is allowed, algorithms such as <a href="Contraction_hierarchy" class="mw-redirect" title="Contraction hierarchy">contraction hierarchies</a> can be up to seven <a href="Orders_of_magnitude" class="mw-redirect" title="Orders of magnitude">orders of magnitude</a> faster.
</p><p>Dijkstra's algorithm is commonly used on graphs where the edge weights are positive integers or real numbers. It can be generalized to any graph where the edge weights are <a href="Partially_ordered_set" title="Partially ordered set">partially ordered</a>, provided the subsequent labels (a subsequent label is produced when traversing an edge) are <a href="Monotonic_function" title="Monotonic function">monotonically</a> non-decreasing.<sup id="cite_ref-Generic_Dijkstra2_10-0" class="reference"><a href="#cite_note-Generic_Dijkstra2-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Generic_Dijkstra_correctness2_11-0" class="reference"><a href="#cite_note-Generic_Dijkstra_correctness2-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup>
</p><p>In many fields, particularly <a href="Artificial_intelligence" title="Artificial intelligence">artificial intelligence</a>, Dijkstra's algorithm or a variant offers a <a class="mw-selflink-fragment" href="#Practical_optimizations_and_infinite_graphs">uniform cost search</a> and is formulated as an instance of the more general idea of <a href="Best-first_search" title="Best-first search">best-first search</a>.<sup id="cite_ref-felner_12-0" class="reference"><a href="#cite_note-felner-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup>
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="History">History</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1244412712">
/* start https://en.wikipedia.org/ */
.mw-parser-output .templatequote{overflow:hidden;margin:1em 0;padding:0 32px}.mw-parser-output .templatequotecite{line-height:1.5em;text-align:left;margin-top:0}@media(min-width:500px){.mw-parser-output .templatequotecite{padding-left:1.6em}}
/* end https://en.wikipedia.org/ */
</style><blockquote class="templatequote"><p>What is the shortest way to travel from <a href="Rotterdam" title="Rotterdam">Rotterdam</a> to <a href="Groningen" title="Groningen">Groningen</a>, in general: from given city to given city. <a href="Shortest_path_problem" title="Shortest path problem">It is the algorithm for the shortest path</a>, which I designed in about twenty minutes. One morning I was shopping in <a href="Amsterdam" title="Amsterdam">Amsterdam</a> with my young fiancée, and tired, we sat down on the café terrace to drink a cup of coffee and I was just thinking about whether I could do this, and I then designed the algorithm for the shortest path. As I said, it was a twenty-minute invention. In fact, it was published in '59, three years later. The publication is still readable, it is, in fact, quite nice. One of the reasons that it is so nice was that I designed it without pencil and paper. I learned later that one of the advantages of designing without pencil and paper is that you are almost forced to avoid all avoidable complexities. Eventually, that algorithm became to my great amazement, one of the cornerstones of my fame.</p></blockquote><div class="templatequotecite"><p style="display: inline; padding-left: 2.3em;">— Edsger Dijkstra, in an interview with Philip L. Frana, Communications of the ACM, 2001<sup id="cite_ref-Dijkstra_Interview2_5-1" class="reference"><a href="#cite_note-Dijkstra_Interview2-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup></p></div>
<p>Dijkstra thought about the shortest path problem while working as a programmer at the <a href="Centrum_Wiskunde_%26_Informatica" title="Centrum Wiskunde & Informatica">Mathematical Center in Amsterdam</a> in 1956. He wanted to demonstrate the capabilities of the new ARMAC computer.<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> His objective was to choose a problem and a computer solution that non-computing people could understand. He designed the shortest path algorithm and later implemented it for ARMAC for a slightly simplified transportation map of 64 cities in the Netherlands (he limited it to 64, so that 6 bits would be sufficient to encode the city number).<sup id="cite_ref-Dijkstra_Interview2_5-2" class="reference"><a href="#cite_note-Dijkstra_Interview2-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> A year later, he came across another problem advanced by hardware engineers working on the institute's next computer: minimize the amount of wire needed to connect the pins on the machine's back panel. As a solution, he re-discovered <a href="Prim's_algorithm" title="Prim's algorithm">Prim's minimal spanning tree algorithm</a> (known earlier to <a href="Vojt%C4%9Bch_Jarn%C3%ADk" title="Vojtěch Jarník">Jarník</a>, and also rediscovered by <a href="Robert_C._Prim" title="Robert C. Prim">Prim</a>).<sup id="cite_ref-EWD841a2_14-0" class="reference"><a href="#cite_note-EWD841a2-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup> Dijkstra published the algorithm in 1959, two years after Prim and 29 years after Jarník.<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Algorithm">Algorithm</h2></div>
<p>The algorithm requires a starting node, and computes the shortest distance from that starting node to each other node. Dijkstra's algorithm starts with infinite distances and tries to improve them step by step:
</p>
<ol><li>Create a <a href="Set_(abstract_data_type)" title="Set (abstract data type)">set</a> of all unvisited nodes: the unvisited set.</li>
<li>Assign to every node a distance from start value: for the starting node, it is zero, and for all other nodes, it is infinity, since initially no path is known to these nodes. During execution, the distance of a node <i>N</i> is the length of the shortest path discovered so far between the starting node and <i>N</i>.<sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup></li>
<li>From the unvisited set, select the current node to be the one with the smallest (finite) distance; initially, this is the starting node (distance zero). If the unvisited set is empty, or contains only nodes with infinite distance (which are unreachable), then the algorithm terminates by skipping to step 6. If the only concern is the path to a target node, the algorithm terminates once the current node is the target node. Otherwise, the algorithm continues.</li>
<li>For the current node, consider all of its unvisited neighbors and update their distances through the current node; compare the newly calculated distance to the one currently assigned to the neighbor and assign the smaller one to it. For example, if the current node <i>A</i> is marked with a distance of 6, and the edge connecting it with its neighbor <i>B</i> has length 2, then the distance to <i>B</i> through <i>A</i> is 6 + 2 = 8. If B was previously marked with a distance greater than 8, then update it to 8 (the path to B through A is shorter). Otherwise, keep its current distance (the path to B through A is not the shortest).</li>
<li>After considering all of the current node's unvisited neighbors, the current node is removed from the unvisited set. Thus a visited node is never rechecked, which is correct because the distance recorded on the current node is minimal (as ensured in step 3), and thus final. Repeat from step 3.</li>
<li>Once the loop exits (steps 3–5), every visited node contains its shortest distance from the starting node.</li></ol>
<div class="mw-heading mw-heading2"><h2 id="Description">Description</h2></div>
<p>The shortest path between two <a href="Intersection_(road)" title="Intersection (road)">intersections</a> on a city map can be found by this algorithm using pencil and paper. Every intersection is listed on a separate line: one is the starting point and is labeled (given a distance of) 0. Every other intersection is initially labeled with a distance of infinity. This is done to note that no path to these intersections has yet been established. At each iteration one intersection becomes the current intersection. For the first iteration, this is the starting point.
</p><p>From the current intersection, the distance to every <a href="Neighbourhood_(graph_theory)" title="Neighbourhood (graph theory)">neighbor</a> (directly-connected) intersection is assessed by summing the label (value) of the current intersection and the distance to the neighbor and then <a href="Graph_labeling" title="Graph labeling">relabeling</a> the neighbor with the lesser of that sum and the neighbor's existing label. I.e., the neighbor is relabeled if the path to it through the current intersection is shorter than previously assessed paths. If so, mark the road to the neighbor with an arrow pointing to it, and erase any other arrow that points to it. After the distances to each of the current intersection's neighbors have been assessed, the current intersection is marked as visited. The unvisited intersection with the smallest label becomes the current intersection and the process repeats until all nodes with labels less than the destination's label have been visited.
</p><p>Once no unvisited nodes remain with a label smaller than the destination's label, the remaining arrows show the shortest path.
</p>
<div class="mw-heading mw-heading2"><h2 id="Pseudocode">Pseudocode</h2></div>
<p>In the following <a href="Pseudocode" title="Pseudocode">pseudocode</a>, <style data-mw-deduplicate="TemplateStyles:r886049734">
/* start https://en.wikipedia.org/ */
.mw-parser-output .monospaced{font-family:monospace,monospace}
/* end https://en.wikipedia.org/ */
</style><span class="monospaced">dist</span> is an array that contains the current distances from the <span class="monospaced"><var>source</var></span> to other vertices, i.e. <span class="monospaced">dist[<var>u</var>]</span> is the current distance from the source to the vertex <span class="monospaced"><var>u</var></span>. The <span class="monospaced">prev</span> array contains pointers to previous-hop nodes on the shortest path from source to the given vertex (equivalently, it is the <i>next-hop</i> on the path <i>from</i> the given vertex <i>to</i> the source). The code <span class="monospaced">u ← vertex in <i>Q</i> with min dist[u]</span>, searches for the vertex <span class="monospaced"><var>u</var></span> in the vertex set <span class="monospaced"><var>Q</var></span> that has the least <span class="monospaced">dist[<var>u</var>]</span> value. <span class="monospaced">Graph.Edges(<var>u</var>, <var>v</var>)</span> returns the length of the edge joining (i.e. the distance between) the two neighbor-nodes <span class="monospaced"><var>u</var></span> and <span class="monospaced"><var>v</var></span>. The variable <span class="monospaced"><var>alt</var></span> on line 14 is the length of the path from the <span class="monospaced"><var>source</var></span> node to the neighbor node <span class="monospaced"><var>v</var></span> if it were to go through <span class="monospaced"><var>u</var></span>. If this path is shorter than the current shortest path recorded for <span class="monospaced"><var>v</var></span>, then the distance of <span class="monospaced"><var>v</var></span> is updated to <span class="monospaced"><var>alt</var></span>.<sup id="cite_ref-mehlhorn_7-1" class="reference"><a href="#cite_note-mehlhorn-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup>
</p>
<pre> 1 <b>function</b> Dijkstra(<i>Graph</i>, <i>source</i>):
2
3 <b>for each</b> vertex <i>v</i> in <i>Graph.Vertices</i>:
4 dist[<i>v</i>] ← INFINITY
5 prev[<i>v</i>] ← UNDEFINED
6 add <i>v</i> to <i>Q</i>
7 dist[<i>source</i>] ← 0
8
9 <b>while</b> <i>Q</i> is not empty:
10 <i>u</i> ← vertex in <i>Q</i> with minimum dist[v]
11 Q.remove(u)
12
13 <b>for each</b> arc (u, v) in <i>Q</i>:
14 <i>alt</i> ← dist[<i>u</i>] + Graph.Edges(<i>u</i>, <i>v</i>)
15 <b>if</b> <i>alt</i> < dist[<i>v</i>]:
16 dist[<i>v</i>] ← <i>alt</i>
17 prev[<i>v</i>] ← <i>u</i>
18
19 <b>return</b> dist[], prev[]
</pre>
<p>To find the shortest path between vertices <span class="monospaced"><var>source</var></span> and <span class="monospaced"><var>target</var></span>, the search terminates after line 10 if <span class="monospaced"><var>u</var> = <var>target</var></span>. The shortest path from <span class="monospaced"><var>source</var></span> to <span class="monospaced"><var>target</var></span> can be obtained by reverse iteration:
</p>
<pre>1 <i>S</i> ← empty sequence
2 <i>u</i> ← <i>target</i>
3 <b>if</b> prev[<i>u</i>] is defined <b>or</b> <i>u</i> = <i>source</i>: <i>// Proceed if the vertex is reachable</i>
4 <b>while</b> <i>u</i> is defined: <i>// Construct the shortest path with a stack S</i>
5 S.push(u) <i>// Push the vertex onto the stack</i>
6 <i>u</i> ← prev[<i>u</i>] <i>// Traverse from target to source</i>
</pre>
<p>Now sequence <span class="monospaced"><var>S</var></span> is the list of vertices constituting one of the shortest paths from <span class="monospaced"><var>source</var></span> to <span class="monospaced"><var>target</var></span>, or the empty sequence if no path exists.
</p><p>A more general problem is to find all the shortest paths between <span class="monospaced"><var>source</var></span> and <span class="monospaced"><var>target</var></span> (there might be several of the same length). Then instead of storing only a single node in each entry of <span class="monospaced">prev[]</span> all nodes satisfying the relaxation condition can be stored. For example, if both <span class="monospaced"><var>r</var></span> and <span class="monospaced"><var>source</var></span> connect to <span class="monospaced"><var>target</var></span> and they lie on different shortest paths through <span class="monospaced"><var>target</var></span> (because the edge cost is the same in both cases), then both <span class="monospaced"><var>r</var></span> and <span class="monospaced"><var>source</var></span> are added to <span class="monospaced">prev[<var>target</var>]</span>. When the algorithm completes, <span class="monospaced">prev[]</span> data structure describes a graph that is a subset of the original graph with some edges removed. Its key property is that if the algorithm was run with some starting node, then every path from that node to any other node in the new graph is the shortest path between those nodes graph, and all paths of that length from the original graph are present in the new graph. Then to actually find all these shortest paths between two given nodes, a path finding algorithm on the new graph, such as <a href="Depth-first_search" title="Depth-first search">depth-first search</a> would work.
</p>
<div class="mw-heading mw-heading3"><h3 id="Using_a_priority_queue">Using a priority queue</h3></div>
<p>A min-priority queue is an abstract data type that provides 3 basic operations: <span class="monospaced">add_with_priority()</span>, <span class="monospaced">decrease_priority()</span> and <span class="monospaced">extract_min()</span>. As mentioned earlier, using such a data structure can lead to faster computing times than using a basic queue. Notably, <a href="Fibonacci_heap" title="Fibonacci heap">Fibonacci heap</a><sup id="cite_ref-FOOTNOTEFredmanTarjan1984_19-0" class="reference"><a href="#cite_note-FOOTNOTEFredmanTarjan1984-19"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup> or <a href="Brodal_queue" title="Brodal queue">Brodal queue</a> offer optimal implementations for those 3 operations. As the algorithm is slightly different in appearance, it is mentioned here, in pseudocode as well:
</p>
<pre>1 <b>function</b> Dijkstra(<i>Graph</i>, <i>source</i>):
2 Q ← Queue storing vertex priority
3
4 dist[<i>source</i>] ← 0 <i>// Initialization</i>
5 <i>Q</i>.add_with_priority(<i>source</i>, 0) <i>// associated priority equals dist[·]</i>
6
7 <b>for each</b> vertex <i>v</i> in <i>Graph.Vertices</i>:
8 <b>if</b> <i>v</i> ≠ <i>source</i>
9 prev[<i>v</i>] ← UNDEFINED <i>// Predecessor of v</i>
10 dist[<i>v</i>] ← INFINITY <i>// Unknown distance from source to v</i>
11 Q.add_with_priority(v, INFINITY)
12
13
14 <b>while</b> <i>Q</i> is not empty: <i>// The main loop</i>
15 <i>u</i> ← <i>Q</i>.extract_min() <i>// Remove and return best vertex</i>
16 <b>for each</b> arc (u, v) : <i>// Go through all v neighbors of u</i>
17 <i>alt</i> ← dist[<i>u</i>] + Graph.Edges(<i>u</i>, <i>v</i>)
18 <b>if</b> <i>alt</i> < dist[<i>v</i>]:
19 prev[<i>v</i>] ← <i>u</i>
20 dist[<i>v</i>] ← <i>alt</i>
21 <i>Q</i>.decrease_priority(<i>v</i>, <i>alt</i>)
22
23 <b>return</b> (dist, prev)
</pre>
<p>Instead of filling the priority queue with all nodes in the initialization phase, it is possible to initialize it to contain only <i>source</i>; then, inside the <code><b>if</b> <i>alt</i> < dist[<i>v</i>]</code> block, the <span class="monospaced">decrease_priority()</span> becomes an <span class="monospaced">add_with_priority()</span> operation.<sup id="cite_ref-mehlhorn_7-2" class="reference"><a href="#cite_note-mehlhorn-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup><sup class="reference nowrap"><span title="Page / location: 198">: 198 </span></sup>
</p><p>Yet another alternative is to add nodes unconditionally to the priority queue and to instead check after extraction (<code><i>u</i> ← <i>Q</i>.extract_min()</code>) that it isn't revisiting, or that no shorter connection was found yet in the <code>if alt < dist[v]</code> block. This can be done by additionally extracting the associated priority <code><i>p</i></code> from the queue and only processing further <code><b>if</b> <i>p</i> == dist[<i>u</i>]</code> inside the <code><b>while</b> <i>Q</i> is not empty</code> loop.<sup id="cite_ref-Note2_20-0" class="reference"><a href="#cite_note-Note2-20"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup>
</p><p>These alternatives can use entirely array-based priority queues without decrease-key functionality, which have been found to achieve even faster computing times in practice. However, the difference in performance was found to be narrower for denser graphs.<sup id="cite_ref-chen_072_21-0" class="reference"><a href="#cite_note-chen_072-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Proof">Proof</h2></div>
<p>To prove the <a href="Correctness_(computer_science)" title="Correctness (computer science)">correctness</a> of Dijkstra's algorithm, <a href="Mathematical_induction" title="Mathematical induction">mathematical induction</a> can be used on the number of visited nodes.<sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup>
</p><p><i>Invariant hypothesis</i>: For each visited node <span class="monospaced">v</span>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[v]</code> is the shortest distance from <span class="monospaced">source</span> to <span class="monospaced">v</span>, and for each unvisited node <span class="monospaced">u</span>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[u]</code> is the shortest distance from <span class="monospaced">source</span> to <span class="monospaced">u</span> when traveling via visited nodes only, or infinity if no such path exists. (Note: we do not assume <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[u]</code> is the actual shortest distance for unvisited nodes, while <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[v]</code> is the actual shortest distance)
</p>
<div class="mw-heading mw-heading3"><h3 id="Base_case">Base case</h3></div>
<p>The base case is when there is just one visited node, <span class="monospaced">source</span>. Its distance is defined to be zero, which is the shortest distance, since negative weights are not allowed. Hence, the hypothesis holds.
</p>
<div class="mw-heading mw-heading3"><h3 id="Induction">Induction</h3></div>
<p>Assuming that the hypothesis holds for <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle k}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>k</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle k}</annotation>
</semantics>
</math></span><img src="./c3c9a2c7b599b37105512c5d570edc034056dd40.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.211ex; height:2.176ex;" alt="{\displaystyle k}" loading="lazy"></span> visited nodes, to show it holds for <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle k+1}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>k</mi>
<mo>+</mo>
<mn>1</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle k+1}</annotation>
</semantics>
</math></span><img src="./552a558062ed4c0486297b5b5531c5ee044dbd9b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:5.214ex; height:2.343ex;" alt="{\displaystyle k+1}" loading="lazy"></span> nodes, let <span class="monospaced">u</span> be the next visited node, i.e. the node with minimum <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[u]</code>. The claim is that <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[u]</code> is the shortest distance from <span class="monospaced">source</span> to <span class="monospaced">u</span>.
</p><p>The proof is by contradiction. If a shorter path were available, then this shorter path either contains another unvisited node or not.
</p>
<ul><li>In the former case, let <span class="monospaced">w</span> be the first unvisited node on this shorter path. By induction, the shortest paths from <span class="monospaced">source</span> to <span class="monospaced">u</span> and <span class="monospaced">w</span> through visited nodes only have costs <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[u]</code> and <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[w]</code> respectively. This means the cost of going from <span class="monospaced">source</span> to <span class="monospaced">u</span> via <span class="monospaced">w</span> has the cost of at least <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[w]</code> + the minimal cost of going from <span class="monospaced">w</span> to <span class="monospaced">u</span>. As the edge costs are positive, the minimal cost of going from <span class="monospaced">w</span> to <span class="monospaced">u</span> is a positive number. However, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[u]</code> is at most <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[w]</code> because otherwise w would have been picked by the priority queue instead of u. This is a contradiction, since it has already been established that <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[w]</code> + a positive number < <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[u]</code>.</li>
<li>In the latter case, let <span class="monospaced">w</span> be the last but one node on the shortest path. That means <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[w] + Graph.Edges[w,u] < dist[u]</code>. That is a contradiction because by the time <span class="monospaced">w</span> is visited, it should have set <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[u]</code> to at most <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[w] + Graph.Edges[w,u]</code>.</li></ul>
<p>For all other visited nodes <span class="monospaced">v</span>, the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[v]</code> is already known to be the shortest distance from <span class="monospaced">source</span> already, because of the inductive hypothesis, and these values are unchanged.
</p><p>After processing <span class="monospaced">u</span>, it is still true that for each unvisited node <span class="monospaced">w</span>, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[w]</code> is the shortest distance from <span class="monospaced">source</span> to <span class="monospaced">w</span> using visited nodes only. Any shorter path that did not use <span class="monospaced">u</span>, would already have been found, and if a shorter path used <span class="monospaced">u</span> it would have been updated when processing <span class="monospaced">u</span>.
</p><p>After all nodes are visited, the shortest path from <span class="monospaced">source</span> to any node <span class="monospaced">v</span> consists only of visited nodes. Therefore, <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">dist[v]</code> is the shortest distance.
</p>
<div class="mw-heading mw-heading2"><h2 id="Running_time">Running time</h2></div>
<p>Bounds of the running time of Dijkstra's algorithm on a graph with edges <i><span class="texhtml mvar" style="font-style:italic;">E</span></i> and vertices <i><span class="texhtml mvar" style="font-style:italic;">V</span></i> can be expressed as a function of the number of edges, denoted <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle |E|}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle |E|}</annotation>
</semantics>
</math></span><img src="./d8c2b9637808cf805d411190b4ae017dbd4ef8d8.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:3.069ex; height:2.843ex;" alt="{\displaystyle |E|}" loading="lazy"></span>, and the number of vertices, denoted <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle |V|}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle |V|}</annotation>
</semantics>
</math></span><img src="./9ddcffc28643ac01a14dd0fb32c3157859e365a7.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:3.081ex; height:2.843ex;" alt="{\displaystyle |V|}" loading="lazy"></span>, using <a href="Big-O_notation" class="mw-redirect" title="Big-O notation">big-O notation</a>. The complexity bound depends mainly on the data structure used to represent the set <i><span class="texhtml mvar" style="font-style:italic;">Q</span></i>. In the following, upper bounds can be simplified because <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle |E|}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle |E|}</annotation>
</semantics>
</math></span><img src="./d8c2b9637808cf805d411190b4ae017dbd4ef8d8.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:3.069ex; height:2.843ex;" alt="{\displaystyle |E|}" loading="lazy"></span> is <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(|V|^{2})}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<msup>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(|V|^{2})}</annotation>
</semantics>
</math></span><img src="./e1e99764e23be92b694aef042c6460ff921357e3.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:7.718ex; height:3.343ex;" alt="{\displaystyle O(|V|^{2})}" loading="lazy"></span> for any simple graph, but that simplification disregards the fact that in some problems, other upper bounds on <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle |E|}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle |E|}</annotation>
</semantics>
</math></span><img src="./d8c2b9637808cf805d411190b4ae017dbd4ef8d8.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:3.069ex; height:2.843ex;" alt="{\displaystyle |E|}" loading="lazy"></span> may hold.
</p><p>For any data structure for the vertex set <i><span class="texhtml mvar" style="font-style:italic;">Q</span></i>, the running time is:<sup id="cite_ref-FOOTNOTECormenLeisersonRivestStein2001_2-1" class="reference"><a href="#cite_note-FOOTNOTECormenLeisersonRivestStein2001-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Theta (|E|\cdot T_{\mathrm {dk} }+|V|\cdot T_{\mathrm {em} }),}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">Θ<!-- Θ --></mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>⋅<!-- ⋅ --></mo>
<msub>
<mi>T</mi>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="normal">d</mi>
<mi mathvariant="normal">k</mi>
</mrow>
</mrow>
</msub>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>⋅<!-- ⋅ --></mo>
<msub>
<mi>T</mi>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="normal">e</mi>
<mi mathvariant="normal">m</mi>
</mrow>
</mrow>
</msub>
<mo stretchy="false">)</mo>
<mo>,</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Theta (|E|\cdot T_{\mathrm {dk} }+|V|\cdot T_{\mathrm {em} }),}</annotation>
</semantics>
</math></span><img src="./b49340c1fc766f10e8b48815b1088cc65898efce.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:23.674ex; height:2.843ex;" alt="{\displaystyle \Theta (|E|\cdot T_{\mathrm {dk} }+|V|\cdot T_{\mathrm {em} }),}" loading="lazy"></span></dd></dl>
<p>where <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle T_{\mathrm {dk} }}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>T</mi>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="normal">d</mi>
<mi mathvariant="normal">k</mi>
</mrow>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle T_{\mathrm {dk} }}</annotation>
</semantics>
</math></span><img src="./9d472cd5eeba8435ca78f0662c29f549a6e68758.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:3.372ex; height:2.509ex;" alt="{\displaystyle T_{\mathrm {dk} }}" loading="lazy"></span> and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle T_{\mathrm {em} }}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>T</mi>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="normal">e</mi>
<mi mathvariant="normal">m</mi>
</mrow>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle T_{\mathrm {em} }}</annotation>
</semantics>
</math></span><img src="./10b20e61c32746a67f380a74d01eb9d672371600.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:3.689ex; height:2.509ex;" alt="{\displaystyle T_{\mathrm {em} }}" loading="lazy"></span> are the complexities of the <i>decrease-key</i> and <i>extract-minimum</i> operations in <i><span class="texhtml mvar" style="font-style:italic;">Q</span></i>, respectively.
</p><p>The simplest version of Dijkstra's algorithm stores the vertex set <i><span class="texhtml mvar" style="font-style:italic;">Q</span></i> as a linked list or array, and edges as an <a href="Adjacency_list" title="Adjacency list">adjacency list</a> or <a href="Adjacency_matrix" title="Adjacency matrix">matrix</a>. In this case, extract-minimum is simply a linear search through all vertices in <i><span class="texhtml mvar" style="font-style:italic;">Q</span></i>, so the running time is <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Theta (|E|+|V|^{2})=\Theta (|V|^{2})}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">Θ<!-- Θ --></mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<msup>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi mathvariant="normal">Θ<!-- Θ --></mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<msup>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Theta (|E|+|V|^{2})=\Theta (|V|^{2})}</annotation>
</semantics>
</math></span><img src="./9cff9c1ad91cc6d7b764f808f068d2233520a233.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:24.513ex; height:3.343ex;" alt="{\displaystyle \Theta (|E|+|V|^{2})=\Theta (|V|^{2})}" loading="lazy"></span>.
</p><p>For <a href="Sparse_graph" class="mw-redirect" title="Sparse graph">sparse graphs</a>, that is, graphs with far fewer than <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle |V|^{2}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<msup>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle |V|^{2}}</annotation>
</semantics>
</math></span><img src="./3e2a7aad37527c097101c39b0b7724fe4e1cafb1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:4.135ex; height:3.343ex;" alt="{\displaystyle |V|^{2}}" loading="lazy"></span> edges, Dijkstra's algorithm can be implemented more efficiently by storing the graph in the form of adjacency lists and using a <a href="Self-balancing_binary_search_tree" title="Self-balancing binary search tree">self-balancing binary search tree</a>, <a href="Binary_heap" title="Binary heap">binary heap</a>, <a href="Pairing_heap" title="Pairing heap">pairing heap</a>, <a href="Fibonacci_heap" title="Fibonacci heap">Fibonacci heap</a> or a priority heap as a <a href="Priority_queue" title="Priority queue">priority queue</a> to implement extracting minimum efficiently. To perform decrease-key steps in a binary heap efficiently, it is necessary to use an auxiliary data structure that maps each vertex to its position in the heap, and to update this structure as the priority queue <i><span class="texhtml mvar" style="font-style:italic;">Q</span></i> changes. With a self-balancing binary search tree or binary heap, the algorithm requires
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Theta ((|E|+|V|)\log |V|)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">Θ<!-- Θ --></mi>
<mo stretchy="false">(</mo>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo stretchy="false">)</mo>
<mi>log</mi>
<mo><!-- --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Theta ((|E|+|V|)\log |V|)}</annotation>
</semantics>
</math></span><img src="./bb876ca772aebc634b2c4087fa81b2d7c683e71c.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:21.244ex; height:2.843ex;" alt="{\displaystyle \Theta ((|E|+|V|)\log |V|)}" loading="lazy"></span></dd></dl>
<p>time in the worst case; for connected graphs this time bound can be simplified to <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Theta (|E|\log |V|)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">Θ<!-- Θ --></mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Theta (|E|\log |V|)}</annotation>
</semantics>
</math></span><img src="./df01952aa6a18b33a028713dedfc2f89d84a3c81.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.514ex; height:2.843ex;" alt="{\displaystyle \Theta (|E|\log |V|)}" loading="lazy"></span>. The <a href="Fibonacci_heap" title="Fibonacci heap">Fibonacci heap</a> improves this to
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Theta (|E|+|V|\log |V|).}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">Θ<!-- Θ --></mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Theta (|E|+|V|\log |V|).}</annotation>
</semantics>
</math></span><img src="./a5f0d0d6da9c8dbd146dae568b1ce2dbf0d65d9a.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:20.082ex; height:2.843ex;" alt="{\displaystyle \Theta (|E|+|V|\log |V|).}" loading="lazy"></span></dd></dl>
<p>When using binary heaps, the <a href="Best%2C_worst_and_average_case" title="Best, worst and average case">average case</a> time complexity is lower than the worst-case: assuming edge costs are drawn independently from a common <a href="Probability_distribution" title="Probability distribution">probability distribution</a>, the expected number of <i>decrease-key</i> operations is bounded by <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Theta (|V|\log(|E|/|V|))}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">Θ<!-- Θ --></mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo stretchy="false">)</mo>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Theta (|V|\log(|E|/|V|))}</annotation>
</semantics>
</math></span><img src="./23857a2943abcd1478c6435680423251fbc1625f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:19.179ex; height:2.843ex;" alt="{\displaystyle \Theta (|V|\log(|E|/|V|))}" loading="lazy"></span>, giving a total running time of<sup id="cite_ref-mehlhorn_7-3" class="reference"><a href="#cite_note-mehlhorn-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup><sup class="reference nowrap"><span title="Page / location: 199–200">: 199–200 </span></sup>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O\left(|E|+|V|\log {\frac {|E|}{|V|}}\log |V|\right).}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mrow>
<mo>(</mo>
<mrow>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
</mrow>
<mrow>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
</mrow>
</mfrac>
</mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
</mrow>
<mo>)</mo>
</mrow>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O\left(|E|+|V|\log {\frac {|E|}{|V|}}\log |V|\right).}</annotation>
</semantics>
</math></span><img src="./518426fe2ac5cff791eee3d85aa084963096e404.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.671ex; width:30.096ex; height:6.509ex;" alt="{\displaystyle O\left(|E|+|V|\log {\frac {|E|}{|V|}}\log |V|\right).}" loading="lazy"></span></dd></dl>
<div class="mw-heading mw-heading3"><h3 id="Practical_optimizations_and_infinite_graphs">Practical optimizations and infinite graphs</h3></div>
<p>In common presentations of Dijkstra's algorithm, initially all nodes are entered into the priority queue. This is, however, not necessary: the algorithm can start with a priority queue that contains only one item, and insert new items as they are discovered (instead of doing a decrease-key, check whether the key is in the queue; if it is, decrease its key, otherwise insert it).<sup id="cite_ref-mehlhorn_7-4" class="reference"><a href="#cite_note-mehlhorn-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup><sup class="reference nowrap"><span title="Page / location: 198">: 198 </span></sup> This variant has the same worst-case bounds as the common variant, but maintains a smaller priority queue in practice, speeding up queue operations.<sup id="cite_ref-felner_12-1" class="reference"><a href="#cite_note-felner-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup>
</p><p>Moreover, not inserting all nodes in a graph makes it possible to extend the algorithm to find the shortest path from a single source to the closest of a set of target nodes on infinite graphs or those too large to represent in memory. The resulting algorithm is called <i>uniform-cost search</i> (UCS) in the artificial intelligence literature<sup id="cite_ref-felner_12-2" class="reference"><a href="#cite_note-felner-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-aima_23-0" class="reference"><a href="#cite_note-aima-23"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup> and can be expressed in pseudocode as
</p>
<pre><b>procedure</b> uniform_cost_search(start) <b>is</b>
node ← start
frontier ← priority queue containing node only
expanded ← empty set
<b>do</b>
<b>if</b> frontier is empty <b>then</b>
<b>return</b> failure
node ← frontier.pop()
<b>if</b> node is a goal state <b>then</b>
<b>return</b> solution(node)
expanded.add(node)
<b>for each</b> of node's neighbors <i>n</i> <b>do</b>
<b>if</b> <i>n</i> is not in expanded and not in frontier <b>then</b>
frontier.add(<i>n</i>)
<b>else if</b> <i>n</i> is in frontier with higher cost
replace existing node with <i>n</i>
</pre>
<p>Its complexity can be expressed in an alternative way for very large graphs: when <span class="texhtml"><i>C</i><sup>*</sup></span> is the length of the shortest path from the start node to any node satisfying the "goal" predicate, each edge has cost at least <i><span class="texhtml mvar" style="font-style:italic;">ε</span></i>, and the number of neighbors per node is bounded by <i><span class="texhtml mvar" style="font-style:italic;">b</span></i>, then the algorithm's worst-case time and space complexity are both in <span class="texhtml"><i>O</i>(<i>b</i><sup>1+⌊<i>C</i><sup>*</sup> <style data-mw-deduplicate="TemplateStyles:r1154941027">
/* start https://en.wikipedia.org/ */
.mw-parser-output .frac{white-space:nowrap}.mw-parser-output .frac .num,.mw-parser-output .frac .den{font-size:80%;line-height:0;vertical-align:super}.mw-parser-output .frac .den{vertical-align:sub}.mw-parser-output .sr-only{border:0;clip:rect(0,0,0,0);clip-path:polygon(0px 0px,0px 0px,0px 0px);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}
/* end https://en.wikipedia.org/ */
</style><span class="frac">⁄</span> <i>ε</i>⌋</sup>)</span>.<sup id="cite_ref-aima_23-1" class="reference"><a href="#cite_note-aima-23"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup>
</p><p>Further optimizations for the single-target case include <a href="Bidirectional_search" title="Bidirectional search">bidirectional</a> variants, goal-directed variants such as the <a href="A*_algorithm" class="mw-redirect" title="A* algorithm">A* algorithm</a> (see <a href="#Related_problems_and_algorithms">§ Related problems and algorithms</a>), graph pruning to determine which nodes are likely to form the middle segment of shortest paths (reach-based routing), and hierarchical decompositions of the input graph that reduce <span class="texhtml"><i>s</i>–<i>t</i></span> routing to connecting <i><span class="texhtml mvar" style="font-style:italic;">s</span></i> and <i><span class="texhtml mvar" style="font-style:italic;">t</span></i> to their respective "<a href="Transit_Node_Routing" class="mw-redirect" title="Transit Node Routing">transit nodes</a>" followed by shortest-path computation between these transit nodes using a "highway".<sup id="cite_ref-speedup2_25-0" class="reference"><a href="#cite_note-speedup2-25"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup> Combinations of such techniques may be needed for optimal practical performance on specific problems.<sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Optimality_for_comparison-sorting_by_distance">Optimality for comparison-sorting by distance</h3></div>
<p>As well as simply computing distances and paths, Dijkstra's algorithm can be used to sort vertices by their distances from a given starting vertex.
In 2023, Haeupler, Rozhoň, Tětek, Hladík, and <a href="Robert_Tarjan" title="Robert Tarjan">Tarjan</a> (one of the inventors of the 1984 heap), proved that, for this sorting problem on a positively-weighted directed graph, a version of Dijkstra's algorithm with a special heap data structure has a runtime and number of comparisons that is within a constant factor of optimal among <a href="Comparison_sort" title="Comparison sort">comparison-based</a> algorithms for the same sorting problem on the same graph and starting vertex but with variable edge weights. To achieve this, they use a comparison-based heap whose cost of returning/removing the minimum element from the heap is logarithmic in the number of elements inserted after it rather than in the number of elements in the heap.<sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">[</span>28<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Specialized_variants">Specialized variants</h3></div>
<p>When arc weights are small integers (bounded by a parameter <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle C}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>C</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle C}</annotation>
</semantics>
</math></span><img src="./4fc55753007cd3c18576f7933f6f089196732029.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.766ex; height:2.176ex;" alt="{\displaystyle C}" loading="lazy"></span>), specialized queues can be used for increased speed. The first algorithm of this type was Dial's algorithm<sup id="cite_ref-FOOTNOTEDial1969_29-0" class="reference"><a href="#cite_note-FOOTNOTEDial1969-29"><span class="cite-bracket">[</span>29<span class="cite-bracket">]</span></a></sup> for graphs with positive integer edge weights, which uses a <a href="Bucket_queue" title="Bucket queue">bucket queue</a> to obtain a running time <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(|E|+|V|C)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>C</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(|E|+|V|C)}</annotation>
</semantics>
</math></span><img src="./8c106890bef1d3c3a6918c4cceb79f2b14aec738.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:14.34ex; height:2.843ex;" alt="{\displaystyle O(|E|+|V|C)}" loading="lazy"></span>. The use of a <a href="Van_Emde_Boas_tree" title="Van Emde Boas tree">Van Emde Boas tree</a> as the priority queue brings the complexity to <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(|E|+|V|\log C/\log \log |V|C)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mi>C</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mi>log</mi>
<mo><!-- --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>C</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(|E|+|V|\log C/\log \log |V|C)}</annotation>
</semantics>
</math></span><img src="./7e90be6df92daa0aff31129584071b6fc43e22c2.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:31.2ex; height:2.843ex;" alt="{\displaystyle O(|E|+|V|\log C/\log \log |V|C)}" loading="lazy"></span> .<sup id="cite_ref-FOOTNOTEAhujaMehlhornOrlinTarjan1990_30-0" class="reference"><a href="#cite_note-FOOTNOTEAhujaMehlhornOrlinTarjan1990-30"><span class="cite-bracket">[</span>30<span class="cite-bracket">]</span></a></sup> Another interesting variant based on a combination of a new <a href="Radix_heap" title="Radix heap">radix heap</a> and the well-known Fibonacci heap runs in time <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(|E|+|V|{\sqrt {\log C}})}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<msqrt>
<mi>log</mi>
<mo><!-- --></mo>
<mi>C</mi>
</msqrt>
</mrow>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(|E|+|V|{\sqrt {\log C}})}</annotation>
</semantics>
</math></span><img src="./ee2a9dfd3f6ca5471b9ecf0f2255bc49f9da6a94.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.171ex; width:20.022ex; height:3.509ex;" alt="{\displaystyle O(|E|+|V|{\sqrt {\log C}})}" loading="lazy"></span> .<sup id="cite_ref-FOOTNOTEAhujaMehlhornOrlinTarjan1990_30-1" class="reference"><a href="#cite_note-FOOTNOTEAhujaMehlhornOrlinTarjan1990-30"><span class="cite-bracket">[</span>30<span class="cite-bracket">]</span></a></sup> Finally, the best algorithms in this special case run in <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(|E|\log \log |V|)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mi>log</mi>
<mo><!-- --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(|E|\log \log |V|)}</annotation>
</semantics>
</math></span><img src="./6ad6d486e8b9d44ea253d43ce5d219652073eb8e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:16.838ex; height:2.843ex;" alt="{\displaystyle O(|E|\log \log |V|)}" loading="lazy"></span><sup id="cite_ref-FOOTNOTEThorup2000_31-0" class="reference"><a href="#cite_note-FOOTNOTEThorup2000-31"><span class="cite-bracket">[</span>31<span class="cite-bracket">]</span></a></sup> time and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(|E|+|V|\min\{(\log |V|)^{1/3+\varepsilon },(\log C)^{1/4+\varepsilon }\})}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>E</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo>+</mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mo movablelimits="true" form="prefix">min</mo>
<mo fence="false" stretchy="false">{</mo>
<mo stretchy="false">(</mo>
<mi>log</mi>
<mo><!-- --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<mi>V</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo stretchy="false">|</mo>
</mrow>
<msup>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mn>3</mn>
<mo>+</mo>
<mi>ε<!-- ε --></mi>
</mrow>
</msup>
<mo>,</mo>
<mo stretchy="false">(</mo>
<mi>log</mi>
<mo><!-- --></mo>
<mi>C</mi>
<msup>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mn>4</mn>
<mo>+</mo>
<mi>ε<!-- ε --></mi>
</mrow>
</msup>
<mo fence="false" stretchy="false">}</mo>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(|E|+|V|\min\{(\log |V|)^{1/3+\varepsilon },(\log C)^{1/4+\varepsilon }\})}</annotation>
</semantics>
</math></span><img src="./7ee874b438d755a44a6327b14b6f8ab107ad7426.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:44.864ex; height:3.343ex;" alt="{\displaystyle O(|E|+|V|\min\{(\log |V|)^{1/3+\varepsilon },(\log C)^{1/4+\varepsilon }\})}" loading="lazy"></span> time.<sup id="cite_ref-FOOTNOTERaman1997_32-0" class="reference"><a href="#cite_note-FOOTNOTERaman1997-32"><span class="cite-bracket">[</span>32<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Related_problems_and_algorithms">Related problems and algorithms</h2></div>
<p>Dijkstra's original algorithm can be extended with modifications. For example, sometimes it is desirable to present solutions which are less than mathematically optimal. To obtain a ranked list of less-than-optimal solutions, the optimal solution is first calculated. A single edge appearing in the optimal solution is removed from the graph, and the optimum solution to this new graph is calculated. Each edge of the original solution is suppressed in turn and a new shortest-path calculated. The secondary solutions are then ranked and presented after the first optimal solution.
</p><p>Dijkstra's algorithm is usually the working principle behind <a href="Link-state_routing_protocol" title="Link-state routing protocol">link-state routing protocols</a>. <a href="OSPF" class="mw-redirect" title="OSPF">OSPF</a> and <a href="IS-IS" title="IS-IS">IS-IS</a> are the most common.
</p><p>Unlike Dijkstra's algorithm, the <a href="Bellman%E2%80%93Ford_algorithm" title="Bellman–Ford algorithm">Bellman–Ford algorithm</a> can be used on graphs with negative edge weights, as long as the graph contains no <a href="Negative_cycle" class="mw-redirect" title="Negative cycle">negative cycle</a> reachable from the source vertex <i>s</i>. The presence of such cycles means that no shortest path can be found, since the label becomes lower each time the cycle is traversed. (This statement assumes that a "path" is allowed to repeat vertices. In <a href="Graph_theory" title="Graph theory">graph theory</a> that is normally not allowed. In <a href="Theoretical_computer_science" title="Theoretical computer science">theoretical computer science</a> it often is allowed.) It is possible to adapt Dijkstra's algorithm to handle negative weights by combining it with the Bellman-Ford algorithm (to remove negative edges and detect negative cycles): <a href="Johnson's_algorithm" title="Johnson's algorithm">Johnson's algorithm</a>.
</p><p>The <a href="A-star_algorithm" class="mw-redirect" title="A-star algorithm">A* algorithm</a> is a generalization of Dijkstra's algorithm that reduces the size of the subgraph that must be explored, if additional information is available that provides a lower bound on the distance to the target.
</p><p>The process that underlies Dijkstra's algorithm is similar to the <a href="Greedy_algorithm" title="Greedy algorithm">greedy</a> process used in <a href="Prim's_algorithm" title="Prim's algorithm">Prim's algorithm</a>. Prim's purpose is to find a <a href="Minimum_spanning_tree" title="Minimum spanning tree">minimum spanning tree</a> that connects all nodes in the graph; Dijkstra is concerned with only two nodes. Prim's does not evaluate the total weight of the path from the starting node, only the individual edges.
</p><p><a href="Breadth-first_search" title="Breadth-first search">Breadth-first search</a> can be viewed as a special-case of Dijkstra's algorithm on unweighted graphs, where the priority queue degenerates into a <a href="FIFO_(computing_and_electronics)" title="FIFO (computing and electronics)">FIFO</a> queue.
</p><p>The <a href="Fast_marching_method" title="Fast marching method">fast marching method</a> can be viewed as a continuous version of Dijkstra's algorithm which computes the geodesic distance on a triangle mesh.
</p>
<div class="mw-heading mw-heading3"><h3 id="Dynamic_programming_perspective">Dynamic programming perspective</h3></div>
<p>From a <a href="Dynamic_programming" title="Dynamic programming">dynamic programming</a> point of view, Dijkstra's algorithm is a successive approximation scheme that solves the dynamic programming functional equation for the shortest path problem by the <b>Reaching</b> method.<sup id="cite_ref-sniedovich_062_33-0" class="reference"><a href="#cite_note-sniedovich_062-33"><span class="cite-bracket">[</span>33<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-denardo_032_34-0" class="reference"><a href="#cite_note-denardo_032-34"><span class="cite-bracket">[</span>34<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-sniedovich_102_35-0" class="reference"><a href="#cite_note-sniedovich_102-35"><span class="cite-bracket">[</span>35<span class="cite-bracket">]</span></a></sup>
</p><p>In fact, Dijkstra's explanation of the logic behind the algorithm:<sup id="cite_ref-FOOTNOTEDijkstra1959270_36-0" class="reference"><a href="#cite_note-FOOTNOTEDijkstra1959270-36"><span class="cite-bracket">[</span>36<span class="cite-bracket">]</span></a></sup>
</p>
<blockquote class="templatequote"><p><b>Problem 2.</b> Find the path of minimum total length between two given nodes <span class="texhtml mvar" style="font-style:italic;">P</span> and <span class="texhtml mvar" style="font-style:italic;">Q</span>.
We use the fact that, if <span class="texhtml mvar" style="font-style:italic;">R</span> is a node on the minimal path from <span class="texhtml mvar" style="font-style:italic;">P</span> to <span class="texhtml mvar" style="font-style:italic;">Q</span>, knowledge of the latter implies the knowledge of the minimal path from <span class="texhtml mvar" style="font-style:italic;">P</span> to <span class="texhtml mvar" style="font-style:italic;">R</span>.</p></blockquote>
<p>is a paraphrasing of <a href="Richard_Bellman" class="mw-redirect" title="Richard Bellman">Bellman's</a> <a href="Bellman_equation#Bellman's_principle_of_optimality" title="Bellman equation">Principle of Optimality</a> in the context of the shortest path problem.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="A*_search_algorithm" title="A* search algorithm">A* search algorithm</a></li>
<li><a href="Bellman%E2%80%93Ford_algorithm" title="Bellman–Ford algorithm">Bellman–Ford algorithm</a></li>
<li><a href="Euclidean_shortest_path" title="Euclidean shortest path">Euclidean shortest path</a></li>
<li><a href="Floyd%E2%80%93Warshall_algorithm" title="Floyd–Warshall algorithm">Floyd–Warshall algorithm</a></li>
<li><a href="Johnson's_algorithm" title="Johnson's algorithm">Johnson's algorithm</a></li>
<li><a href="Longest_path_problem" title="Longest path problem">Longest path problem</a></li>
<li><a href="Parallel_all-pairs_shortest_path_algorithm" title="Parallel all-pairs shortest path algorithm">Parallel all-pairs shortest path algorithm</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2></div>
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text">Controversial, see <style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFMoshe_Sniedovich2006" class="citation journal cs1">Moshe Sniedovich (2006). <a rel="nofollow" class="external text" href="https://www.infona.pl/resource/bwmeta1.element.baztech-article-BAT5-0013-0005/tab/summary">"Dijkstra's algorithm revisited: the dynamic programming connexion"</a>. <i>Control and Cybernetics</i>. <b>35</b>: <span class="nowrap">599–</span>620.</cite> and <a href="#Dynamic_programming_perspective">below part</a>.</span>
</li>
<li id="cite_note-FOOTNOTECormenLeisersonRivestStein2001-2"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTECormenLeisersonRivestStein2001_2-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTECormenLeisersonRivestStein2001_2-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFCormenLeisersonRivestStein2001">Cormen et al. 2001</a>.</span>
</li>
<li id="cite_note-FOOTNOTEFredmanTarjan1987-3"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEFredmanTarjan1987_3-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEFredmanTarjan1987_3-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFFredmanTarjan1987">Fredman & Tarjan 1987</a>.</span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite id="CITEREFRichards" class="citation web cs1">Richards, Hamilton. <a rel="nofollow" class="external text" href="http://amturing.acm.org/award_winners/dijkstra_1053701.cfm">"Edsger Wybe Dijkstra"</a>. <i>A.M. Turing Award</i>. Association for Computing Machinery<span class="reference-accessdate">. Retrieved <span class="nowrap">16 October</span> 2017</span>. <q>At the Mathematical Centre a major project was building the ARMAC computer. For its official inauguration in 1956, Dijkstra devised a program to solve a problem interesting to a nontechnical audience: Given a network of roads connecting cities, what is the shortest route between two designated cities?</q></cite></span>
</li>
<li id="cite_note-Dijkstra_Interview2-5"><span class="mw-cite-backlink">^ <a href="#cite_ref-Dijkstra_Interview2_5-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Dijkstra_Interview2_5-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-Dijkstra_Interview2_5-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFFrana2010" class="citation journal cs1">Frana, Phil (August 2010). "An Interview with Edsger W. Dijkstra". <i>Communications of the ACM</i>. <b>53</b> (8): <span class="nowrap">41–</span>47. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F1787234.1787249">10.1145/1787234.1787249</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:27009702">27009702</a>.</cite></span>
</li>
<li id="cite_note-Dijkstra19592-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-Dijkstra19592_6-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFDijkstra1959" class="citation journal cs1"><a href="Edsger_W._Dijkstra" title="Edsger W. Dijkstra">Dijkstra, E. W.</a> (1959). <a rel="nofollow" class="external text" href="https://ir.cwi.nl/pub/9256/9256D.pdf">"A note on two problems in connexion with graphs"</a> <span class="cs1-format">(PDF)</span>. <i>Numerische Mathematik</i>. <b>1</b>: <span class="nowrap">269–</span>271. <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a> <span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.165.7577">10.1.1.165.7577</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2FBF01386390">10.1007/BF01386390</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:123284777">123284777</a>.</cite></span>
</li>
<li id="cite_note-mehlhorn-7"><span class="mw-cite-backlink">^ <a href="#cite_ref-mehlhorn_7-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-mehlhorn_7-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-mehlhorn_7-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-mehlhorn_7-3"><sup><i><b>d</b></i></sup></a> <a href="#cite_ref-mehlhorn_7-4"><sup><i><b>e</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFMehlhornSanders2008" class="citation book cs1"><a href="Kurt_Mehlhorn" title="Kurt Mehlhorn">Mehlhorn, Kurt</a>; <a href="Peter_Sanders_(computer_scientist)" title="Peter Sanders (computer scientist)">Sanders, Peter</a> (2008). <a rel="nofollow" class="external text" href="http://people.mpi-inf.mpg.de/~mehlhorn/ftp/Toolbox/ShortestPaths.pdf">"Chapter 10. Shortest Paths"</a> <span class="cs1-format">(PDF)</span>. <i>Algorithms and Data Structures: The Basic Toolbox</i>. Springer. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F978-3-540-77978-0">10.1007/978-3-540-77978-0</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-3-540-77977-3</bdi>.</cite></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite id="CITEREFSchrijver2012" class="citation book cs1">Schrijver, Alexander (2012). <a rel="nofollow" class="external text" href="http://ftp.gwdg.de/pub/misc/EMIS/journals/DMJDMV/vol-ismp/32_schrijver-alexander-sp.pdf">"On the history of the shortest path problem"</a> <span class="cs1-format">(PDF)</span>. <i>Optimization Stories</i>. Documenta Mathematica Series. Vol. 6. pp. <span class="nowrap">155–</span>167. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.4171%2Fdms%2F6%2F19">10.4171/dms/6/19</a></span>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-3-936609-58-5</bdi>.</cite></span>
</li>
<li id="cite_note-FOOTNOTELeyzorekGrayJohnsonLadew1957-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTELeyzorekGrayJohnsonLadew1957_9-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFLeyzorekGrayJohnsonLadew1957">Leyzorek et al. 1957</a>.</span>
</li>
<li id="cite_note-Generic_Dijkstra2-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-Generic_Dijkstra2_10-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFSzcześniakJajszczykWoźna-Szcześniak2019" class="citation journal cs1">Szcześniak, Ireneusz; Jajszczyk, Andrzej; Woźna-Szcześniak, Bożena (2019). "Generic Dijkstra for optical networks". <i>Journal of Optical Communications and Networking</i>. <b>11</b> (11): <span class="nowrap">568–</span>577. <a href="ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1810.04481">1810.04481</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1364%2FJOCN.11.000568">10.1364/JOCN.11.000568</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:52958911">52958911</a>.</cite></span>
</li>
<li id="cite_note-Generic_Dijkstra_correctness2-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-Generic_Dijkstra_correctness2_11-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFSzcześniakWoźna-Szcześniak2023" class="citation cs2">Szcześniak, Ireneusz; Woźna-Szcześniak, Bożena (2023), "Generic Dijkstra: Correctness and tractability", <i>NOMS 2023-2023 IEEE/IFIP Network Operations and Management Symposium</i>, pp. <span class="nowrap">1–</span>7, <a href="ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/2204.13547">2204.13547</a></span>, <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FNOMS56928.2023.10154322">10.1109/NOMS56928.2023.10154322</a>, <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-1-6654-7716-1</bdi>, <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:248427020">248427020</a></cite></span>
</li>
<li id="cite_note-felner-12"><span class="mw-cite-backlink">^ <a href="#cite_ref-felner_12-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-felner_12-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-felner_12-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFFelner2011" class="citation conference cs1">Felner, Ariel (2011). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20200218150924/https://www.aaai.org/ocs/index.php/SOCS/SOCS11/paper/view/4017/4357"><i>Position Paper: Dijkstra's Algorithm versus Uniform Cost Search or a Case Against Dijkstra's Algorithm</i></a>. Proc. 4th Int'l Symp. on Combinatorial Search. Archived from <a rel="nofollow" class="external text" href="http://www.aaai.org/ocs/index.php/SOCS/SOCS11/paper/view/4017/4357">the original</a> on 18 February 2020<span class="reference-accessdate">. Retrieved <span class="nowrap">12 February</span> 2015</span>.</cite> In a route-finding problem, Felner finds that the queue can be a factor 500–600 smaller, taking some 40% of the running time.</span>
</li>
<li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20131113021126/http://www-set.win.tue.nl/UnsungHeroes/machines/armac.html">"ARMAC"</a>. <i>Unsung Heroes in Dutch Computing History</i>. 2007. Archived from <a rel="nofollow" class="external text" href="http://www-set.win.tue.nl/UnsungHeroes/machines/armac.html">the original</a> on 13 November 2013.</cite></span>
</li>
<li id="cite_note-EWD841a2-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-EWD841a2_14-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFDijkstra" class="citation cs2">Dijkstra, Edsger W., <a rel="nofollow" class="external text" href="https://www.cs.utexas.edu/users/EWD/ewd08xx/EWD841a.PDF"><i>Reflections on "A note on two problems in connexion with graphs</i></a> <span class="cs1-format">(PDF)</span></cite></span>
</li>
<li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><cite id="CITEREFTarjan1983" class="citation cs2"><a href="Robert_Endre_Tarjan" class="mw-redirect" title="Robert Endre Tarjan">Tarjan, Robert Endre</a> (1983), <i>Data Structures and Network Algorithms</i>, CBMS_NSF Regional Conference Series in Applied Mathematics, vol. 44, Society for Industrial and Applied Mathematics, p. 75, <q>The third classical minimum spanning tree algorithm was discovered by Jarník and rediscovered by Prim and Dikstra; it is commonly known as Prim's algorithm.</q></cite></span>
</li>
<li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><cite id="CITEREFPrim1957" class="citation journal cs1">Prim, R.C. (1957). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170718230207/http://bioinfo.ict.ac.cn/~dbu/AlgorithmCourses/Lectures/Prim1957.pdf">"Shortest connection networks and some generalizations"</a> <span class="cs1-format">(PDF)</span>. <i>Bell System Technical Journal</i>. <b>36</b> (6): <span class="nowrap">1389–</span>1401. <a href="Bibcode_(identifier)" class="mw-redirect" title="Bibcode (identifier)">Bibcode</a>:<a rel="nofollow" class="external text" href="https://ui.adsabs.harvard.edu/abs/1957BSTJ...36.1389P">1957BSTJ...36.1389P</a>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1002%2Fj.1538-7305.1957.tb01515.x">10.1002/j.1538-7305.1957.tb01515.x</a>. Archived from <a rel="nofollow" class="external text" href="http://bioinfo.ict.ac.cn/~dbu/AlgorithmCourses/Lectures/Prim1957.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 18 July 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">18 July</span> 2017</span>.</cite></span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text">V. Jarník: <i>O jistém problému minimálním</i> [About a certain minimal problem], Práce Moravské Přírodovědecké Společnosti, 6, 1930, pp. 57–63. (in Czech)</span>
</li>
<li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><cite id="CITEREFGassFu2013" class="citation encyclopaedia cs1">Gass, Saul; Fu, Michael (2013). "Dijkstra's Algorithm". In Gass, Saul I; Fu, Michael C (eds.). <i>Encyclopedia of Operations Research and Management Science</i>. Vol. 1. Springer. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F978-1-4419-1153-7">10.1007/978-1-4419-1153-7</a></span>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-1-4419-1137-7</bdi> – via Springer Link.</cite></span>
</li>
<li id="cite_note-FOOTNOTEFredmanTarjan1984-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEFredmanTarjan1984_19-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFFredmanTarjan1984">Fredman & Tarjan 1984</a>.</span>
</li>
<li id="cite_note-Note2-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-Note2_20-0">^</a></b></span> <span class="reference-text">Observe that <span class="monospaced"><i>p</i> < dist[<i>u</i>]</span> cannot ever hold because of the update <span class="monospaced">dist[<i>v</i>] ← <i>alt</i></span> when updating the queue. See <a rel="nofollow" class="external free" href="https://cs.stackexchange.com/questions/118388/dijkstra-without-decrease-key">https://cs.stackexchange.com/questions/118388/dijkstra-without-decrease-key</a> for discussion.</span>
</li>
<li id="cite_note-chen_072-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-chen_072_21-0">^</a></b></span> <span class="reference-text"><cite id="chen" class="citation book cs1">Chen, M.; Chowdhury, R. A.; Ramachandran, V.; Roche, D. L.; Tong, L. (2007). <a rel="nofollow" class="external text" href="http://www.cs.sunysb.edu/~rezaul/papers/TR-07-54.pdf"><i>Priority Queues and Dijkstra's Algorithm – UTCS Technical Report TR-07-54 – 12 October 2007</i></a> <span class="cs1-format">(PDF)</span>. Austin, Texas: The University of Texas at Austin, Department of Computer Sciences.</cite></span>
</li>
<li id="cite_note-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-22">^</a></b></span> <span class="reference-text"><cite id="CITEREFCormenLeisersonRivestStein2022" class="citation book cs1"><a href="Thomas_H._Cormen" title="Thomas H. Cormen">Cormen, Thomas H.</a>; <a href="Charles_E._Leiserson" title="Charles E. Leiserson">Leiserson, Charles E.</a>; <a href="Ron_Rivest" title="Ron Rivest">Rivest, Ronald L.</a>; <a href="Clifford_Stein" title="Clifford Stein">Stein, Clifford</a> (2022) [1990]. "22". <a href="Introduction_to_Algorithms" title="Introduction to Algorithms"><i>Introduction to Algorithms</i></a> (4th ed.). MIT Press and McGraw-Hill. pp. <span class="nowrap">622–</span>623. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-262-04630-X</bdi>.</cite></span>
</li>
<li id="cite_note-aima-23"><span class="mw-cite-backlink">^ <a href="#cite_ref-aima_23-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-aima_23-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFRussellNorvig2009" class="citation book cs1"><a href="Stuart_J._Russell" title="Stuart J. Russell">Russell, Stuart</a>; <a href="Peter_Norvig" title="Peter Norvig">Norvig, Peter</a> (2009) [1995]. <i><a href="Artificial_Intelligence%3A_A_Modern_Approach" title="Artificial Intelligence: A Modern Approach">Artificial Intelligence: A Modern Approach</a></i> (3rd ed.). Prentice Hall. pp. 75, 81. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-13-604259-4</bdi>.</cite></span>
</li>
<li id="cite_note-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-24">^</a></b></span> <span class="reference-text">Sometimes also <i>least-cost-first search</i>: <cite id="CITEREFNau1983" class="citation journal cs1">Nau, Dana S. (1983). <a rel="nofollow" class="external text" href="https://www.cs.umd.edu/~nau/papers/nau1983expert.pdf">"Expert computer systems"</a> <span class="cs1-format">(PDF)</span>. <i>Computer</i>. <b>16</b> (2). IEEE: <span class="nowrap">63–</span>85. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2Fmc.1983.1654302">10.1109/mc.1983.1654302</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:7301753">7301753</a>.</cite></span>
</li>
<li id="cite_note-speedup2-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-speedup2_25-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFWagnerWillhalm2007" class="citation conference cs1">Wagner, Dorothea; Willhalm, Thomas (2007). <i>Speed-up techniques for shortest-path computations</i>. STACS. pp. <span class="nowrap">23–</span>36.</cite></span>
</li>
<li id="cite_note-26"><span class="mw-cite-backlink"><b><a href="#cite_ref-26">^</a></b></span> <span class="reference-text"><cite id="CITEREFBauerDellingSandersSchieferdecker2010" class="citation journal cs1">Bauer, Reinhard; Delling, Daniel; Sanders, Peter; Schieferdecker, Dennis; Schultes, Dominik; Wagner, Dorothea (2010). <a rel="nofollow" class="external text" href="https://publikationen.bibliothek.kit.edu/1000014952">"Combining hierarchical and goal-directed speed-up techniques for Dijkstra's algorithm"</a>. <i>ACM Journal of Experimental Algorithmics</i>. <b>15</b>: 2.1. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F1671970.1671976">10.1145/1671970.1671976</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:1661292">1661292</a>.</cite></span>
</li>
<li id="cite_note-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-27">^</a></b></span> <span class="reference-text"><cite id="CITEREFHaeuplerHladíkRozhoňTarjan2024" class="citation arxiv cs1">Haeupler, Bernhard; Hladík, Richard; Rozhoň, Václav; Tarjan, Robert; Tětek, Jakub (28 October 2024). "Universal Optimality of Dijkstra via Beyond-Worst-Case Heaps". <a href="ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/2311.11793">2311.11793</a></span> [<a rel="nofollow" class="external text" href="https://arxiv.org/archive/cs.DS">cs.DS</a>].</cite></span>
</li>
<li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text"><cite id="CITEREFBrubaker2024" class="citation web cs1">Brubaker, Ben (25 October 2024). <a rel="nofollow" class="external text" href="https://www.quantamagazine.org/computer-scientists-establish-the-best-way-to-traverse-a-graph-20241025/">"Computer Scientists Establish the Best Way to Traverse a Graph"</a>. <i>Quanta Magazine</i><span class="reference-accessdate">. Retrieved <span class="nowrap">9 December</span> 2024</span>.</cite></span>
</li>
<li id="cite_note-FOOTNOTEDial1969-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEDial1969_29-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFDial1969">Dial 1969</a>.</span>
</li>
<li id="cite_note-FOOTNOTEAhujaMehlhornOrlinTarjan1990-30"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEAhujaMehlhornOrlinTarjan1990_30-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEAhujaMehlhornOrlinTarjan1990_30-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFAhujaMehlhornOrlinTarjan1990">Ahuja et al. 1990</a>.</span>
</li>
<li id="cite_note-FOOTNOTEThorup2000-31"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEThorup2000_31-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFThorup2000">Thorup 2000</a>.</span>
</li>
<li id="cite_note-FOOTNOTERaman1997-32"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTERaman1997_32-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFRaman1997">Raman 1997</a>.</span>
</li>
<li id="cite_note-sniedovich_062-33"><span class="mw-cite-backlink"><b><a href="#cite_ref-sniedovich_062_33-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFSniedovich2006" class="citation journal cs1">Sniedovich, M. (2006). <a rel="nofollow" class="external text" href="http://matwbn.icm.edu.pl/ksiazki/cc/cc35/cc3536.pdf">"Dijkstra's algorithm revisited: the dynamic programming connexion"</a> <span class="cs1-format">(PDF)</span>. <i>Journal of Control and Cybernetics</i>. <b>35</b> (3): <span class="nowrap">599–</span>620.</cite> <a rel="nofollow" class="external text" href="http://www.ifors.ms.unimelb.edu.au/tutorial/dijkstra_new/index.html">Online version of the paper with interactive computational modules.</a></span>
</li>
<li id="cite_note-denardo_032-34"><span class="mw-cite-backlink"><b><a href="#cite_ref-denardo_032_34-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFDenardo2003" class="citation book cs1">Denardo, E.V. (2003). <i>Dynamic Programming: Models and Applications</i>. Mineola, NY: <a href="Dover_Publications" title="Dover Publications">Dover Publications</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-486-42810-9</bdi>.</cite></span>
</li>
<li id="cite_note-sniedovich_102-35"><span class="mw-cite-backlink"><b><a href="#cite_ref-sniedovich_102_35-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFSniedovich2010" class="citation book cs1">Sniedovich, M. (2010). <i>Dynamic Programming: Foundations and Principles</i>. Francis & Taylor. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-8247-4099-3</bdi>.</cite></span>
</li>
<li id="cite_note-FOOTNOTEDijkstra1959270-36"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEDijkstra1959270_36-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFDijkstra1959">Dijkstra 1959</a>, p. 270.</span>
</li>
</ol></div>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<ul><li><cite id="CITEREFCormenLeisersonRivestStein2001" class="citation book cs1"><a href="Thomas_H._Cormen" title="Thomas H. Cormen">Cormen, Thomas H.</a>; <a href="Charles_E._Leiserson" title="Charles E. Leiserson">Leiserson, Charles E.</a>; <a href="Ronald_L._Rivest" class="mw-redirect" title="Ronald L. Rivest">Rivest, Ronald L.</a>; <a href="Clifford_Stein" title="Clifford Stein">Stein, Clifford</a> (2001). "Section 24.3: Dijkstra's algorithm". <a href="Introduction_to_Algorithms" title="Introduction to Algorithms"><i>Introduction to Algorithms</i></a> (Second ed.). <a href="MIT_Press" title="MIT Press">MIT Press</a> and <a href="McGraw%E2%80%93Hill" class="mw-redirect" title="McGraw–Hill">McGraw–Hill</a>. pp. <span class="nowrap">595–</span>601. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-262-03293-7</bdi>.</cite></li>
<li><cite id="CITEREFDial1969" class="citation journal cs1">Dial, Robert B. (1969). <a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F363269.363610">"Algorithm 360: Shortest-path forest with topological ordering [H]"</a>. <i><a href="Communications_of_the_ACM" title="Communications of the ACM">Communications of the ACM</a></i>. <b>12</b> (11): <span class="nowrap">632–</span>633. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F363269.363610">10.1145/363269.363610</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:6754003">6754003</a>.</cite></li>
<li><cite id="CITEREFFredmanTarjan1984" class="citation conference cs1"><a href="Michael_Fredman" title="Michael Fredman">Fredman, Michael Lawrence</a>; <a href="Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert E.</a> (1984). <i>Fibonacci heaps and their uses in improved network optimization algorithms</i>. 25th Annual Symposium on Foundations of Computer Science. <a href="IEEE" class="mw-redirect" title="IEEE">IEEE</a>. pp. <span class="nowrap">338–</span>346. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FSFCS.1984.715934">10.1109/SFCS.1984.715934</a>.</cite></li>
<li><cite id="CITEREFFredmanTarjan1987" class="citation journal cs1"><a href="Michael_Fredman" title="Michael Fredman">Fredman, Michael Lawrence</a>; <a href="Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert E.</a> (1987). <a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F28869.28874">"Fibonacci heaps and their uses in improved network optimization algorithms"</a>. <i>Journal of the Association for Computing Machinery</i>. <b>34</b> (3): <span class="nowrap">596–</span>615. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F28869.28874">10.1145/28869.28874</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:7904683">7904683</a>.</cite></li>
<li><cite id="CITEREFZhanNoon1998" class="citation journal cs1">Zhan, F. Benjamin; Noon, Charles E. (February 1998). "Shortest Path Algorithms: An Evaluation Using Real Road Networks". <i><a href="Transportation_Science" title="Transportation Science">Transportation Science</a></i>. <b>32</b> (1): <span class="nowrap">65–</span>73. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1287%2Ftrsc.32.1.65">10.1287/trsc.32.1.65</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:14986297">14986297</a>.</cite></li>
<li><cite id="CITEREFLeyzorekGrayJohnsonLadew1957" class="citation book cs1">Leyzorek, M.; Gray, R. S.; Johnson, A. A.; Ladew, W. C.; Meaker, Jr., S. R.; Petry, R. M.; Seitz, R. N. (1957). <i>Investigation of Model Techniques – First Annual Report – 6 June 1956 – 1 July 1957 – A Study of Model Techniques for Communication Systems</i>. Cleveland, Ohio: Case Institute of Technology.</cite></li>
<li><cite id="CITEREFKnuth1977" class="citation journal cs1"><a href="Donald_Knuth" title="Donald Knuth">Knuth, D.E.</a> (1977). "A Generalization of Dijkstra's Algorithm". <i><a href="Information_Processing_Letters" title="Information Processing Letters">Information Processing Letters</a></i>. <b>6</b> (1): <span class="nowrap">1–</span>5. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1016%2F0020-0190%2877%2990002-3">10.1016/0020-0190(77)90002-3</a>.</cite></li>
<li><cite id="CITEREFAhujaMehlhornOrlinTarjan1990" class="citation journal cs1">Ahuja, Ravindra K.; Mehlhorn, Kurt; Orlin, James B.; Tarjan, Robert E. (April 1990). <a rel="nofollow" class="external text" href="https://dspace.mit.edu/bitstream/1721.1/47994/1/fasteralgorithms00sloa.pdf">"Faster Algorithms for the Shortest Path Problem"</a> <span class="cs1-format">(PDF)</span>. <i>Journal of the ACM</i>. <b>37</b> (2): <span class="nowrap">213–</span>223. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F77600.77615">10.1145/77600.77615</a>. <a href="Hdl_(identifier)" class="mw-redirect" title="Hdl (identifier)">hdl</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://hdl.handle.net/1721.1%2F47994">1721.1/47994</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:5499589">5499589</a>.</cite></li>
<li><cite id="CITEREFRaman1997" class="citation journal cs1">Raman, Rajeev (1997). <a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F261342.261352">"Recent results on the single-source shortest paths problem"</a>. <i>SIGACT News</i>. <b>28</b> (2): <span class="nowrap">81–</span>87. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F261342.261352">10.1145/261342.261352</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:18031586">18031586</a>.</cite></li>
<li><cite id="CITEREFThorup2000" class="citation journal cs1">Thorup, Mikkel (2000). "On RAM priority Queues". <i>SIAM Journal on Computing</i>. <b>30</b> (1): <span class="nowrap">86–</span>109. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1137%2FS0097539795288246">10.1137/S0097539795288246</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:5221089">5221089</a>.</cite></li>
<li><cite id="CITEREFThorup1999" class="citation journal cs1">Thorup, Mikkel (1999). <a rel="nofollow" class="external text" href="http://www.diku.dk/~mthorup/PAPERS/sssp.ps.gz">"Undirected single-source shortest paths with positive integer weights in linear time"</a>. <i>Journal of the ACM</i>. <b>46</b> (3): <span class="nowrap">362–</span>394. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F316542.316548">10.1145/316542.316548</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:207654795">207654795</a>.</cite></li></ul>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1290876196">
/* start https://en.wikipedia.org/ */
.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .infobox .side-box{font-size:100%}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1237033735">
/* start https://en.wikipedia.org/ */
@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}
/* end https://en.wikipedia.org/ */
</style><div class="side-box side-box-right sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">
/* start https://en.wikipedia.org/ */
.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}
/* end https://en.wikipedia.org/ */
</style>
<div class="side-box-flex">
<div class="side-box-image"><span class="noviewer" typeof="mw:File"></span></div>
<div class="side-box-text plainlist">Wikimedia Commons has media related to <span style="font-weight: bold; font-style: italic;"><a href="https://commons.wikimedia.org/wiki/Category:Dijkstra%27s_algorithm" class="extiw external" title="commons:Category:Dijkstra's algorithm">Dijkstra's algorithm</a></span>.</div></div>
</div>
<ul><li><a rel="nofollow" class="external text" href="http://purl.umn.edu/107247">Oral history interview with Edsger W. Dijkstra</a>, <a href="Charles_Babbage_Institute" class="mw-redirect" title="Charles Babbage Institute">Charles Babbage Institute</a>, University of Minnesota, Minneapolis</li>
<li><a rel="nofollow" class="external text" href="http://blog.cleancoder.com/uncle-bob/2016/10/26/DijkstrasAlg.html">Implementation of Dijkstra's algorithm using TDD</a>, <a href="Robert_Cecil_Martin" class="mw-redirect" title="Robert Cecil Martin">Robert Cecil Martin</a>, The Clean Code Blog</li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Edsger_Dijkstra318" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="3"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div id="Edsger_Dijkstra318" style="font-size:114%;margin:0 4em"><a href="Edsger_W._Dijkstra" title="Edsger W. Dijkstra">Edsger Dijkstra</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%">Works</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><i>A Primer of ALGOL 60 Programming</i> (book)</li>
<li><i>Structured Programming</i> (book)</li>
<li><i>A Discipline of Programming</i> (book)</li>
<li><i>A Method of Programming</i> (book)</li>
<li><i>Predicate Calculus and Program Semantics</i> (book)</li>
<li><i>Selected Writings on Computing: A Personal Perspective</i> (book)</li>
<li><i>A Note on Two Problems in Connexion with Graphs</i></li>
<li><i>Cooperating Sequential Processes</i></li>
<li><i>Solution of a Problem in Concurrent Programming Control</i></li>
<li><i>The Structure of the 'THE'-Multiprogramming System</i></li>
<li><i><a href="Go_To_Statement_Considered_Harmful" class="mw-redirect" title="Go To Statement Considered Harmful">Go To Statement Considered Harmful</a></i></li>
<li><i>Notes on Structured Programming</i></li>
<li><i>The Humble Programmer</i></li>
<li><i>Programming Considered as a Human Activity</i></li>
<li><i>How Do We Tell Truths That Might Hurt?</i></li>
<li><i>On the Role of Scientific Thought</i></li>
<li><i>Self-stabilizing Systems in Spite of Distributed Control</i></li>
<li><i><a href="On_the_Cruelty_of_Really_Teaching_Computer_Science" title="On the Cruelty of Really Teaching Computer Science">On the Cruelty of Really Teaching Computer Science</a></i></li>
<li><a href="Edsger_W._Dijkstra#Selected_publications" title="Edsger W. Dijkstra">Selected papers</a></li>
<li><a href="EWDs" class="mw-redirect" title="EWDs">EWD manuscripts</a></li></ul>
</div></td><td class="noviewer navbox-image" rowspan="3" style="width:1px;padding:0 0 0 2px"><div><span typeof="mw:File"></span></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Computer_science#Areas_of_computer_science" title="Computer science">Main research<br>areas</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Theoretical_computer_science" title="Theoretical computer science">Theoretical computing science</a></li>
<li><a href="Software_engineering" title="Software engineering">Software engineering</a></li>
<li><a href="Systems_science" title="Systems science">Systems science</a></li>
<li><a href="Algorithm_design" class="mw-redirect" title="Algorithm design">Algorithm design</a> ()</li>
<li><a href="Concurrent_computing" title="Concurrent computing">Concurrent computing</a></li>
<li><a href="Distributed_computing" title="Distributed computing">Distributed computing</a></li>
<li><a href="Formal_methods" title="Formal methods">Formal methods</a></li>
<li><a href="Programming_methodology" class="mw-redirect" title="Programming methodology">Programming methodology</a></li>
<li><a href="Programming_language_research" class="mw-redirect" title="Programming language research">Programming language research</a></li>
<li><a href="Software_design" title="Software design">Program design</a> and <a href="Software_development" title="Software development">development</a></li>
<li><a href="Software_architecture" title="Software architecture">Software architecture</a></li>
<li><a href="Philosophy_of_computer_science" title="Philosophy of computer science">Philosophy of computer programming and computing science</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Related<br>people</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Shlomi_Dolev" title="Shlomi Dolev">Shlomi Dolev</a></li>
<li><a href="Per_Brinch_Hansen" title="Per Brinch Hansen">Per Brinch Hansen</a></li>
<li><a href="Tony_Hoare" title="Tony Hoare">Tony Hoare</a></li>
<li><a href="Ole-Johan_Dahl" title="Ole-Johan Dahl">Ole-Johan Dahl</a></li>
<li><a href="Leslie_Lamport" title="Leslie Lamport">Leslie Lamport</a></li>
<li><a href="David_Parnas" title="David Parnas">David Parnas</a></li>
<li><a href="Jaap_A._Zonneveld" title="Jaap A. Zonneveld">Jaap A. Zonneveld</a></li>
<li><a href="Carel_S._Scholten" title="Carel S. Scholten">Carel S. Scholten</a></li>
<li><a href="Adriaan_van_Wijngaarden" title="Adriaan van Wijngaarden">Adriaan van Wijngaarden</a></li>
<li><a href="Niklaus_Wirth" title="Niklaus Wirth">Niklaus Wirth</a></li></ul>
</div></td></tr><tr><td class="navbox-abovebelow plainlist" colspan="3"><div>
<ul><li><span class="noviewer" typeof="mw:File"><span title="Wikiquote page"></span></span> <a href="https://en.wikiquote.org/wiki/Special:Search/Edsger_W._Dijkstra" class="extiw external" title="wikiquote:Special:Search/Edsger W. Dijkstra"><b>Wikiquote</b></a></li></ul>
</div></td></tr></tbody></table></div>
<div class="navbox-styles"></div><div role="navigation" class="navbox" aria-labelledby="Graph_and_tree_traversal_algorithms231" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="Graph_and_tree_traversal_algorithms231" style="font-size:114%;margin:0 4em"><a href="Graph_traversal" title="Graph traversal">Graph</a> and <a href="Tree_traversal" title="Tree traversal">tree</a> traversal algorithms</div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Graph_traversal" title="Graph traversal">Search</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Alpha%E2%80%93beta_pruning" title="Alpha–beta pruning">α–β pruning</a></li>
<li><a href="A*_search_algorithm" title="A* search algorithm"><b>A*</b></a>
<ul><li><a href="Iterative_deepening_A*" title="Iterative deepening A*">IDA*</a></li>
<li><a href="Lifelong_Planning_A*" title="Lifelong Planning A*">LPA*</a></li>
<li><a href="SMA*" title="SMA*">SMA*</a></li></ul></li>
<li><a href="Best-first_search" title="Best-first search">Best-first search</a></li>
<li><a href="Beam_search" title="Beam search">Beam search</a></li>
<li><a href="Bidirectional_search" title="Bidirectional search">Bidirectional search</a></li>
<li><a href="Breadth-first_search" title="Breadth-first search">Breadth-first search</a>
<ul><li><a href="Lexicographic_breadth-first_search" title="Lexicographic breadth-first search">Lexicographic</a></li>
<li><a href="Parallel_breadth-first_search" title="Parallel breadth-first search">Parallel</a></li></ul></li>
<li><a href="B*" title="B*">B*</a></li>
<li><a href="Depth-first_search" title="Depth-first search">Depth-first search</a>
<ul><li><a href="Iterative_deepening_depth-first_search" title="Iterative deepening depth-first search">Iterative deepening</a></li></ul></li>
<li><a href="D*" title="D*">D*</a></li>
<li><a href="Fringe_search" title="Fringe search">Fringe search</a></li>
<li><a href="Jump_point_search" title="Jump point search">Jump point search</a></li>
<li><a href="Monte_Carlo_tree_search" title="Monte Carlo tree search">Monte Carlo tree search</a></li>
<li><a href="SSS*" title="SSS*">SSS*</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Shortest_path_problem" title="Shortest path problem">Shortest path</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bellman%E2%80%93Ford_algorithm" title="Bellman–Ford algorithm">Bellman–Ford</a></li>
<li><a href="Floyd%E2%80%93Warshall_algorithm" title="Floyd–Warshall algorithm">Floyd–Warshall</a></li>
<li><a href="Johnson's_algorithm" title="Johnson's algorithm">Johnson's</a></li>
<li><a href="Shortest_path_faster_algorithm" class="mw-redirect" title="Shortest path faster algorithm">Shortest path faster</a></li>
<li><a href="Yen's_algorithm" title="Yen's algorithm">Yen's</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Minimum_spanning_tree" title="Minimum spanning tree">Minimum spanning tree</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bor%C5%AFvka's_algorithm" title="Borůvka's algorithm">Borůvka's</a></li>
<li><a href="Kruskal's_algorithm" title="Kruskal's algorithm">Kruskal's</a></li>
<li><a href="Prim's_algorithm" title="Prim's algorithm">Prim's</a></li>
<li><a href="Reverse-delete_algorithm" title="Reverse-delete algorithm">Reverse-delete</a></li></ul>
</div></td></tr><tr><td class="navbox-abovebelow" colspan="2"><div><a href="List_of_algorithms#Graph_search" title="List of algorithms">List of graph search algorithms</a></div></td></tr></tbody></table></div>
<div class="navbox-styles"></div><div role="navigation" class="navbox" aria-labelledby="Optimization:_Algorithms,_methods,_and_heuristics381" style="padding:3px"><table class="nowraplinks hlist mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="3"><div id="Optimization:_Algorithms,_methods,_and_heuristics381" style="font-size:114%;margin:0 4em"><a href="Mathematical_optimization" title="Mathematical optimization">Optimization</a>: <a href="Optimization_algorithm" class="mw-redirect" title="Optimization algorithm">Algorithms</a>, <a href="Iterative_method" title="Iterative method">methods</a>, and <a href="Heuristic_algorithm" class="mw-redirect" title="Heuristic algorithm">heuristics</a></div></th></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks mw-collapsible mw-collapsed navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="Unconstrained_nonlinear381" style="font-size:114%;margin:0 4em"><a href="Nonlinear_programming" title="Nonlinear programming">Unconstrained nonlinear</a></div></th></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Function_(mathematics)" title="Function (mathematics)">Functions</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Golden-section_search" title="Golden-section search">Golden-section search</a></li>
<li><a href="Powell's_method" title="Powell's method">Powell's method</a></li>
<li><a href="Line_search" title="Line search">Line search</a></li>
<li><a href="Nelder%E2%80%93Mead_method" title="Nelder–Mead method">Nelder–Mead method</a></li>
<li><a href="Successive_parabolic_interpolation" title="Successive parabolic interpolation">Successive parabolic interpolation</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Gradient" title="Gradient">Gradients</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Local_convergence" title="Local convergence">Convergence</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Trust_region" title="Trust region">Trust region</a></li>
<li><a href="Wolfe_conditions" title="Wolfe conditions">Wolfe conditions</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Quasi-Newton_method" title="Quasi-Newton method">Quasi–Newton</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Berndt%E2%80%93Hall%E2%80%93Hall%E2%80%93Hausman_algorithm" title="Berndt–Hall–Hall–Hausman algorithm">Berndt–Hall–Hall–Hausman</a></li>
<li><a href="Broyden%E2%80%93Fletcher%E2%80%93Goldfarb%E2%80%93Shanno_algorithm" title="Broyden–Fletcher–Goldfarb–Shanno algorithm">Broyden–Fletcher–Goldfarb–Shanno</a> and <a href="Limited-memory_BFGS" title="Limited-memory BFGS">L-BFGS</a></li>
<li><a href="Davidon%E2%80%93Fletcher%E2%80%93Powell_formula" title="Davidon–Fletcher–Powell formula">Davidon–Fletcher–Powell</a></li>
<li><a href="Symmetric_rank-one" title="Symmetric rank-one">Symmetric rank-one (SR1)</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Iterative_method" title="Iterative method">Other methods</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Nonlinear_conjugate_gradient_method" title="Nonlinear conjugate gradient method">Conjugate gradient</a></li>
<li><a href="Gauss%E2%80%93Newton_algorithm" title="Gauss–Newton algorithm">Gauss–Newton</a></li>
<li><a href="Gradient_descent" title="Gradient descent">Gradient</a></li>
<li><a href="Mirror_descent" title="Mirror descent">Mirror</a></li>
<li><a href="Levenberg%E2%80%93Marquardt_algorithm" title="Levenberg–Marquardt algorithm">Levenberg–Marquardt</a></li>
<li><a href="Powell's_dog_leg_method" title="Powell's dog leg method">Powell's dog leg method</a></li>
<li><a href="Truncated_Newton_method" title="Truncated Newton method">Truncated Newton</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Hessian_matrix" title="Hessian matrix">Hessians</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Newton's_method_in_optimization" title="Newton's method in optimization">Newton's method</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr></tbody></table><div></div></td><td class="noviewer navbox-image" rowspan="5" style="width:1px;padding:0 0 0 2px"><div></div></td></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks mw-collapsible mw-collapsed navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="Constrained_nonlinear381" style="font-size:114%;margin:0 4em"><a href="Nonlinear_programming" title="Nonlinear programming">Constrained nonlinear</a></div></th></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%">General</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Barrier_function" title="Barrier function">Barrier methods</a></li>
<li><a href="Penalty_method" title="Penalty method">Penalty methods</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Differentiable</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Augmented_Lagrangian_method" title="Augmented Lagrangian method">Augmented Lagrangian methods</a></li>
<li><a href="Sequential_quadratic_programming" title="Sequential quadratic programming">Sequential quadratic programming</a></li>
<li><a href="Successive_linear_programming" title="Successive linear programming">Successive linear programming</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr></tbody></table><div></div></td></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks mw-collapsible mw-collapsed navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="Convex_optimization381" style="font-size:114%;margin:0 4em"><a href="Convex_optimization" title="Convex optimization">Convex optimization</a></div></th></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Convex_minimization" class="mw-redirect" title="Convex minimization">Convex<br> minimization</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Cutting-plane_method" title="Cutting-plane method">Cutting-plane method</a></li>
<li><a href="Frank%E2%80%93Wolfe_algorithm" title="Frank–Wolfe algorithm">Reduced gradient (Frank–Wolfe)</a></li>
<li><a href="Subgradient_method" title="Subgradient method">Subgradient method</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Linear_programming" title="Linear programming">Linear</a> and<br><a href="Quadratic_programming" title="Quadratic programming">quadratic</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Linear_programming#Interior_point" title="Linear programming">Interior point</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Affine_scaling" title="Affine scaling">Affine scaling</a></li>
<li><a href="Ellipsoid_method" title="Ellipsoid method">Ellipsoid algorithm of Khachiyan</a></li>
<li><a href="Karmarkar's_algorithm" title="Karmarkar's algorithm">Projective algorithm of Karmarkar</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Matroid" title="Matroid">Basis-</a><a href="Exchange_algorithm" class="mw-redirect" title="Exchange algorithm">exchange</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Simplex_algorithm" title="Simplex algorithm">Simplex algorithm of Dantzig</a></li>
<li><a href="Revised_simplex_method" title="Revised simplex method">Revised simplex algorithm</a></li>
<li><a href="Criss-cross_algorithm" title="Criss-cross algorithm">Criss-cross algorithm</a></li>
<li><a href="Lemke's_algorithm" title="Lemke's algorithm">Principal pivoting algorithm of Lemke</a></li>
<li><a href="Active-set_method" title="Active-set method">Active-set method</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr></tbody></table><div></div></td></tr></tbody></table><div></div></td></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks mw-collapsible uncollapsed navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="Combinatorial381" style="font-size:114%;margin:0 4em"><a href="Combinatorial_optimization" title="Combinatorial optimization">Combinatorial</a></div></th></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%">Paradigms</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Approximation_algorithm" title="Approximation algorithm">Approximation algorithm</a></li>
<li><a href="Dynamic_programming" title="Dynamic programming">Dynamic programming</a></li>
<li><a href="Greedy_algorithm" title="Greedy algorithm">Greedy algorithm</a></li>
<li><a href="Integer_programming" title="Integer programming">Integer programming</a>
<ul><li><a href="Branch_and_bound" title="Branch and bound">Branch and bound</a>/<a href="Branch_and_cut" title="Branch and cut">cut</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Graph_algorithm" class="mw-redirect" title="Graph algorithm">Graph<br> algorithms</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th id="Minimum_spanning_tree52" scope="row" class="navbox-group" style="width:1%"><a href="Minimum_spanning_tree" title="Minimum spanning tree">Minimum<br> spanning tree</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bor%C5%AFvka's_algorithm" title="Borůvka's algorithm">Borůvka</a></li>
<li><a href="Prim's_algorithm" title="Prim's algorithm">Prim</a></li>
<li><a href="Kruskal's_algorithm" title="Kruskal's algorithm">Kruskal</a></li></ul>
</div></td></tr></tbody></table><div>
</div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th id="Shortest_path39" scope="row" class="navbox-group" style="width:1%"><a href="Shortest_path_problem" title="Shortest path problem">Shortest path</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bellman%E2%80%93Ford_algorithm" title="Bellman–Ford algorithm">Bellman–Ford</a>
<ul><li><a href="Shortest_Path_Faster_Algorithm" class="mw-redirect" title="Shortest Path Faster Algorithm">SPFA</a></li></ul></li>
<li><a href="Floyd%E2%80%93Warshall_algorithm" title="Floyd–Warshall algorithm">Floyd–Warshall</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Flow_network" title="Flow network">Network flows</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Dinic's_algorithm" title="Dinic's algorithm">Dinic</a></li>
<li><a href="Edmonds%E2%80%93Karp_algorithm" title="Edmonds–Karp algorithm">Edmonds–Karp</a></li>
<li><a href="Ford%E2%80%93Fulkerson_algorithm" title="Ford–Fulkerson algorithm">Ford–Fulkerson</a></li>
<li><a href="Push%E2%80%93relabel_maximum_flow_algorithm" title="Push–relabel maximum flow algorithm">Push–relabel maximum flow</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr></tbody></table><div></div></td></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks mw-collapsible mw-collapsed navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="Metaheuristics381" style="font-size:114%;margin:0 4em"><a href="Metaheuristic" title="Metaheuristic">Metaheuristics</a></div></th></tr><tr><td colspan="2" class="navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Evolutionary_algorithm" title="Evolutionary algorithm">Evolutionary algorithm</a></li>
<li><a href="Hill_climbing" title="Hill climbing">Hill climbing</a></li>
<li><a href="Local_search_(optimization)" title="Local search (optimization)">Local search</a></li>
<li><a href="Parallel_metaheuristic" title="Parallel metaheuristic">Parallel metaheuristics</a></li>
<li><a href="Simulated_annealing" title="Simulated annealing">Simulated annealing</a></li>
<li><a href="Spiral_optimization_algorithm" title="Spiral optimization algorithm">Spiral optimization algorithm</a></li>
<li><a href="Tabu_search" title="Tabu search">Tabu search</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><td class="navbox-abovebelow" colspan="3"><div>
<ul><li><a href="Comparison_of_optimization_software" title="Comparison of optimization software">Software</a></li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-21" href="https://en.wikipedia.org/wiki/?title=Dijkstra's_algorithm&oldid=1301664509">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>